From 48814c8d1e9788afe87d3e29a33d17610d632850 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 11 Jun 2011 04:06:22 +0200 Subject: [PATCH] themingengine: Do pattern merging smarter Create an intermdiate surface and fill() with it later. Instead of doing clip + paint twice. --- gtk/gtkthemingengine.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 51c80b431e..863ea8c050 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1510,7 +1510,7 @@ render_background_internal (GtkThemingEngine *engine, cairo_pattern_t *pattern; GtkStateFlags flags; gboolean running; - gdouble progress, alpha = 1; + gdouble progress; GtkCssBorderCornerRadius *top_left_radius, *top_right_radius; GtkCssBorderCornerRadius *bottom_left_radius, *bottom_right_radius; GtkCssBorderRadius border_radius = { { 0, }, }; @@ -1641,22 +1641,22 @@ render_background_internal (GtkThemingEngine *engine, } else { - /* Different pattern types, or different color - * stop counts, alpha blend both patterns. - */ - _cairo_round_rectangle_sides (cr, &border_radius, - 0, 0, width, height, - SIDE_ALL); + cairo_save (cr); + + cairo_rectangle (cr, 0, 0, width, height); + cairo_clip (cr); + + cairo_push_group (cr); cairo_scale (cr, width, height); cairo_set_source (cr, other_pattern); - cairo_scale (cr, 1.0 / width, 1.0 / height); - cairo_fill_preserve (cr); + cairo_paint_with_alpha (cr, progress); + cairo_set_source (cr, pattern); + cairo_paint_with_alpha (cr, 1.0 - progress); + + new_pattern = cairo_pop_group (cr); - /* Set alpha for posterior drawing - * of the target pattern - */ - alpha = 1 - progress; + cairo_restore (cr); } } else if (pattern || other_pattern) @@ -1740,17 +1740,7 @@ render_background_internal (GtkThemingEngine *engine, else gdk_cairo_set_source_rgba (cr, &bg_color); - if (alpha == 1) - { - cairo_fill (cr); - } - else - { - cairo_save (cr); - cairo_clip (cr); - cairo_paint_with_alpha (cr, alpha); - cairo_restore (cr); - } + cairo_fill (cr); if (pattern) cairo_pattern_destroy (pattern); -- 2.30.2